package cn.jietuo.juc.c_000;

import java.util.concurrent.TimeUnit;

/**
 * @author zhangx & jietuo_zx@163.com
 * @version 1.0
 * @date 2020/5/2
 * @description: 什么是线程
 */
public class T01_WhatIsThread {

    public static void main(String[] args) {
        T1 t1 = new T1();
//        t1.run();
        t1.start();

        for (int i = 0; i < 10; i++) {
            try {
                TimeUnit.MICROSECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("main:" + i);
        }
    }


    private static class T1 extends Thread {

        @Override
        public void run() {
            for (int i = 0; i < 10; i++) {
                try {
                    TimeUnit.MICROSECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("T1:" + i);
            }
        }
    }
}
